<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../public/vue.js"></script>
</head>
<body>
<div id="app">
    <div>{{this.total}}</div>
    <div v-on:click="add1">点击这里将data1增加1:{{data1}}</div>
    <div v-on:click="add2">点击这里将data1增加1:{{data2}}</div>
</div>
<script>
    const app = new Vue({
        el: "#app",
        data: {
            data1: 1,
            data2: 2
        },
        methods: {
            add1: function () {
                this.data1++;
            },
            add2: function () {
                this.data2++;
            },
        },
        computed: {
            total: function () {
                return this.data1 + this.data2
            }
        }
    });
</script>

</body>
</html>